package com.itheima.sc.web.ums;

import com.itheima.sc.pojo.ums.UmsResourceCategory;
import com.itheima.sc.result.Result;
import com.itheima.sc.service.ums.UmsResourceCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("resourceCategory")
public class UmsResourceCategoryController {
    @Autowired
    private UmsResourceCategoryService umsResourceCategoryService;

    /**
     * 添加后台资源分类
     */
    @PostMapping("create")
    public Result create(@RequestBody UmsResourceCategory umsResourceCategory) {
        umsResourceCategoryService.create(umsResourceCategory);
        return Result.success(null);
    }

    /**
     * 根据ID删除后台资源
     */
    @PostMapping("delete/{id}")
    public Result delete(@PathVariable Integer id) {
        umsResourceCategoryService.delete(id);
        return Result.success(null);
    }

    /**
     * 查询所有后台资源分类
     */
    @GetMapping("listAll")
    public Result listAll() {
        List<UmsResourceCategory> list = umsResourceCategoryService.listAll();
        return Result.success(list);
    }

    /**
     * 修改后台资源分类
     */
    @PostMapping("update/{id}")
    public Result update(@RequestBody UmsResourceCategory umsResourceCategory) {
        umsResourceCategoryService.update(umsResourceCategory);
        return Result.success(null);
    }

}
